<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core">

	<h:outputText rendered="#{pontoBean.saveState}">
		<div class="innerTitle">Cadastro de Ponto</div>
	</h:outputText>

	<h:outputText rendered="#{pontoBean.updateState}">
		<div class="innerTitle">Atualização de Ponto</div>
	</h:outputText>

	<h:inputHidden id="lat" value="#{pontoBean.lat}" required="true"/>
	<h:inputHidden id="lng" value="#{pontoBean.lng}" required="true"/>
	<h:inputHidden value="#{pontoBean.entity.id}" rendered="#{pontoBean.updateState}"/>
	<h:inputHidden value="#{pontoBean.entity.status}" rendered="#{pontoBean.updateState}"/>

	<c:if test="#{!controlBean.administradorSistema}">
		<h:inputHidden value="#{pontoBean.entity.cliente.id}" rendered="#{pontoBean.updateState}" />
	</c:if>


	<rich:tabPanel switchType="client">

       <rich:tab label="Cadastro">

			<h:inputText id="consultaPonto" maxlength="80" size="50">
					</h:inputText>
					<a4j:commandButton value="Consultar Ponto" onclick="showAddress();" styleClass="button"/>
				<h:outputLabel style="color:red; font-family:arial; font-weight:bold" value="Ex: Av. Senador Virgílio Távora 2001 - Fortaleza - CE"/>

		<h:panelGrid columns="6" styleClass="crud" columnClasses="label">
			<h:outputLabel value="Descrição do Ponto:"/>
				<h:inputText id="nomePonto" value="#{pontoBean.entity.nome}" required="true" maxlength="50" size="50">
					<f:validateLength maximum="50"/>
					<rich:ajaxValidator event="onblur"/>
				</h:inputText>
				<rich:message errorClass="error" for="nomePonto"/>

				<h:outputLabel value="Cód. Ponto Cliente :" />
					<h:inputText id="codigoPonto" value="#{pontoBean.entity.codigoPonto}" required="false" maxlength="8" size="8">
						<f:validateLength maximum="8" />
						<rich:ajaxValidator event="onblur" />
					</h:inputText>
				<rich:message errorClass="error" for="codigoPontoo" />

				<h:outputLabel value="Visualizar ponto no mapa:" />
					<h:selectBooleanCheckbox id="pontoMapa" value="${pontoBean.entity.statusMapa}"/>
				<rich:message errorClass="error" for="pontoMapa" />

				<c:if test="#{controlBean.administradorSistema}">
					<h:outputLabel value="Cliente :" />
					<h:selectOneMenu id="clientePonto" value="#{pontoBean.entity.cliente.id}">
						<f:selectItems value="#{clienteBean.listaClientes}" />
					</h:selectOneMenu>
					<rich:message for="clientePonto" />
				</c:if>

			</h:panelGrid>

			<div id="mapponto" class="mapponto" style="width: 100%; height: 250px;"></div>

		</rich:tab>

	</rich:tabPanel>

	<br/>

	<a4j:commandButton value="Inserir" type="submit" action="#{pontoBean.save}" styleClass="button" rendered="#{pontoBean.saveState}" reRender="popup"/>
	<a4j:commandButton value="Atualizar" type="submit" action="#{pontoBean.update}" styleClass="button" rendered="#{pontoBean.updateState}" reRender="popup"/>
	<a4j:commandButton value="Voltar" type="submit" action="#{pontoBean.search}" styleClass="button" immediate="true" reRender="popup"/>

</ui:composition>